#ifndef SERIALLIST_H
#define SERIALLIST_H

#include <QObject>
#include <QSerialPortInfo>
#include <QMap>
#include "serialthread.h"

namespace Moolink {

    class SerialList : public QObject
    {
    public:
        SerialList(QObject *parent = nullptr);
        ~SerialList();

        QStringList SerialRefresh(bool hand=false);
        void writeDataToSerial(int devIndex,QString devname,QString portname,int BaudRate,int DataBits,int Parity,int StopBits,int waitMSEC,QByteArray dataByte);
        void testEmit();

        // 设置回调函数的函数
        void setCallbackFunc(void(*func) (int devIndex,QString devName,QByteArray res,int error));

    private:
            void(*m_callbackFunc)(int devIndex,QString devName,QByteArray res,int error);
    signals:
        void response(const QString &s);
        void error(const QString &s);
        //void timeout(const QString &s);
    private slots:
        void transaction();
        void showRequest(int devIndex,const QString &devName,const QByteArray &res);
        void processError(int devIndex,const QString &devName,const QString &s);
        void processTimeout(int devIndex,const QString &devName,const QString &s);
    };
}
#endif // SERIALLIST_H
